package org.dftproject.pgv.ui;

import java.io.File;

import org.dftproject.genesis.ui.pages.AbstractPageInput;
import org.dftproject.pgv.core.racp.PGVGedcom;

public class PGVPageInput extends AbstractPageInput {
	
	private PGVGedcom pGVGedcom;
	
	public PGVPageInput(PGVGedcom pGVGedcom) {
		setPGVGedcom(pGVGedcom);
	}
	
	public PGVGedcom getPGVGedcom() {
		return pGVGedcom;
	}
	
	public void setPGVGedcom(PGVGedcom pGVGedcom) {
		this.pGVGedcom = pGVGedcom;
		setLabel(pGVGedcom.getTitle());
		setImageDescriptor(Activator.getImageDescriptor("icons/world.png"));
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((pGVGedcom == null) ? 0 : pGVGedcom.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final PGVPageInput other = (PGVPageInput) obj;
		if (pGVGedcom == null) {
			if (other.pGVGedcom != null)
				return false;
		} else if (!pGVGedcom.equals(other.pGVGedcom))
			return false;
		return true;
	}
	
	protected String getName(String path) {
		File file = new File(path);
		return file.getName().replaceFirst("\\.[^.]*$", "");
	}

}
